package com.heima.wemedia.controller.v1;

import com.heima.model.common.admin.dtos.AdChannelDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.wemedia.service.AdChannelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 杨尚杰
 * @data 2024/8/1 10:48
 */
@RestController
@Slf4j
@RequestMapping("/api/v1/channel")
public class AdminChannelController {

    @Autowired
    private AdChannelService adChannelService;

    /**
     * 频道分页查询
     * @param channelDto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult queryPage(@RequestBody AdChannelDto channelDto){
        log.info("频道查询: {}",channelDto);
        return adChannelService.queryPage(channelDto);
    }

    /**
     * 频道保存
     * @param channelDto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult saveChannel(@RequestBody AdChannelDto channelDto){
        log.info("频道保存: {}",channelDto);
        return adChannelService.saveChannel(channelDto);
    }

    /**
     * 修改频道
     * @param channelDto
     * @return
     */
    @PostMapping("/update")
    public ResponseResult updateChannel(@RequestBody AdChannelDto channelDto){
        log.info("频道修改: {}",channelDto);
        return adChannelService.updateChannel(channelDto);
    }

    /**
     * 删除频道
     * @param id
     * @return
     */
    @GetMapping("/del/{id}")
    public ResponseResult delChannel(@PathVariable Integer id){
        log.info("删除频道: {}",id);
        return adChannelService.delChannel(id);
    }
}
